﻿using nanhua.BookStore.EntityFrameworkCore;
using nanhua.BookStore.Entitys.OrderAggregate;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using System.Linq.Dynamic.Core;
using Microsoft.EntityFrameworkCore;

namespace nanhua.BookStore.Repositorys
{
    public class EfCoreOrderRepository : EfCoreRepository<BookStoreDbContext, Order, Guid>, IOrderRepository
    {
        public EfCoreOrderRepository(
           IDbContextProvider<BookStoreDbContext> dbContextProvider)
           : base(dbContextProvider)
        {
        }


        public async Task<List<Order>> GetListAsync(int skipCount, int maxResultCount, string sorting)
        {
            var dbSet = await this.GetDbSetAsync();
            var result = await dbSet.OrderBy(sorting).Skip(skipCount).Take(maxResultCount).Include(c=>c.OrderDetails).ToListAsync();
            
            return result;
        }
    }
}
